local tianze = fk.CreateSkill {

  name = "joy__tianze",

  tags = {  },

}



tianze:addEffect(fk.CardUseFinished, {
  name = "joy__tianze",
  events = {fk.CardUseFinished},
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(tianze.name) and target ~= player and target.phase == Player.Play and data.card.color == Card.Black and
    player:usedSkillTimes(tianze.name, Player.HistoryTurn) == 0 and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, true, tianze.name, true, ".|.|spade,club|hand,equip", "#joy__tianze-invoke::"..target.id, true)
    if #card > 0 then
      event:setCostData(self, card)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    room:throwCard(event:getCostData(self), tianze.name, player, player)
    room:damage{ from = player, to = target, damage = 1, skillName = tianze.name}
  end,
})

tianze:addEffect(fk.FinishJudge, {
  name = "#joy__tianze_draw",
  events = {fk.FinishJudge},
  anim_type = "drawcard",
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(tianze.name) and data.card.color == Card.Black
  end,
  on_cost = function() return true end,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke(tianze.name)
    player.room:notifySkillInvoked(player, tianze.name, self.anim_type)
    player.room:drawCards(player, 1, tianze.name)
  end,
})

return tianze